package org.example.springbookdamo.Dao;

import org.example.springbookdamo.model.Bookinfo;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@Component
public class BookDao {
    /*
     * mock 应该从数据库中查询数据的
     * */
    public List<Bookinfo> mockData(){
        List<Bookinfo> bookinfos = new ArrayList<>();
        for (int i = 1; i <= 15; i++) {
            Bookinfo bookinfo = new Bookinfo();
            bookinfo.setBookId(i);
            bookinfo.setName("图书"+i);
            bookinfo.setAuthor("作者"+i);
            bookinfo.setPublish("出版社"+i);
            bookinfo.setNum(new Random().nextInt(100));
            bookinfo.setPrice(new BigDecimal(new Random().nextInt(100)));
            bookinfo.setStatus(i%5 == 0?2:1);//1表示可以借阅，2表示不可借阅
            bookinfos.add(bookinfo);
        }
        return bookinfos;
    }

}
